<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<#if generatorTable.inputTypes?contains("3")>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
</#if>
<#if generatorTable.inputTypes?contains("4") || generatorTable.inputTypes?contains("5")>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
</#if>
<#if generatorTable.inputTypes?contains("5")>
<%@ taglib prefix="cyys" uri="http://www.cyys.com/cyystaglib"%>
</#if>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit">
  	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<title>${'$'}{SYSTEM_NAME}</title>
	<link rel="stylesheet" href="${'$'}{pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css?v=${'$'}{FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${'$'}{pageContext.request.contextPath}/static/layuiadmin/style/admin.css?v=${'$'}{FILE_VERSION}" media="all">
	<#if generatorTable.inputTypes?contains("4") || generatorTable.inputTypes?contains("5")>
	<link rel="stylesheet" href="${'$'}{pageContext.request.contextPath}/static/css/fileUpload.css?v=${'$'}{FILE_VERSION}">
	</#if>
</head>
<body>
<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body" style="padding: 15px;">
		<form class="layui-form" method="post" id="basicform" >
			<input id="id" name="id" value="${'$'}{${generatorTable.className}.id }" type="hidden">

			<div class="layui-form-item">
				<label class="layui-form-label">上级${generatorTable.tableComment!""}</label>
				<div class="layui-input-inline">
					<input type="hidden" id="parentId" name="parentId" value="${'$'}{${generatorTable.className}.parentId}" >
					<input type="text" id="parentName" class="layui-input" readonly="readonly" value="${'$'}{${generatorTable.className}.parentName}"
						   placeholder="点击选择上级${generatorTable.tableComment!""}" onclick="select${generatorTable.upperClassName}()">
				</div>
				<div class="layui-input-inline">
					<button type="button" class="layui-btn" onclick="${generatorTable.className}Select()">点击选择</button>
				</div>
			</div>

			<#if generatorTable.fieldList?exists && generatorTable.fieldList?size gt 0>
				<#list generatorTable.fieldList as fieldItem >
					<#if fieldItem.inputType =='1'>
			<div class="layui-form-item">
				<label class="layui-form-label<#if fieldItem.required != '0'> layui-form-required</#if>">${fieldItem.columnComment!""}
				</label>
				<div class="layui-input-block">
					<input name="${fieldItem.fieldName}" placeholder="请输入${fieldItem.columnComment!""}"
						   class="layui-input" value="${'$'}{${generatorTable.className}.${fieldItem.fieldName} }"
							<#if fieldItem.required != '0'>
						   lay-verify="${fieldItem.required}"
							</#if>
							<#if fieldItem.columnLength1 != -1>
						   maxlength="${fieldItem.columnLength1}"
							</#if>/>
				</div>
			</div>

					</#if>
					<#if fieldItem.inputType =='2'>
			<div class="layui-form-item">
				<label class="layui-form-label<#if fieldItem.required != '0'> layui-form-required</#if>">${fieldItem.columnComment!""}
				</label>
				<div class="layui-input-block">
					<textarea name="${fieldItem.fieldName}" placeholder="请输入${fieldItem.columnComment!""}"
						   class="layui-textarea"
							<#if fieldItem.required != '0'>
								lay-verify="${fieldItem.required}"
							</#if>
							<#if fieldItem.columnLength1 != -1>
							  maxlength="${fieldItem.columnLength1}"
							</#if>>${'$'}{${generatorTable.className}.${fieldItem.fieldName} }</textarea>
				</div>
			</div>

					</#if>
					<#if fieldItem.inputType =='3'>
			<div class="layui-form-item">
				<label class="layui-form-label<#if fieldItem.required != '0'> layui-form-required</#if>">${fieldItem.columnComment!""}
				</label>
				<div class="layui-input-block">
					<input type="text" id="${fieldItem.fieldName}" name="${fieldItem.fieldName}" placeholder="点击选择${fieldItem.columnComment!""}"
						class="layui-input" value='<fmt:formatDate value="${'$'}{${generatorTable.className}.${fieldItem.fieldName}}" pattern="yyyy-MM-dd" />'
					<#if fieldItem.required != '0'>
						lay-verify="${fieldItem.required}"
					</#if> readonly="readonly" />
				</div>
			</div>

					</#if>
					<#if fieldItem.inputType =='4'>
			<div class="layui-form-item">
				<label class="layui-form-label">${fieldItem.columnComment!""}</label>
				<div class="layui-input-block">
					<div class="layui-upload-list"  style="width:100px">
						<input class="fileUrl" value="${'$'}{${generatorTable.className}.${fieldItem.fieldName}}" name="${fieldItem.fieldName}"
								<#if fieldItem.required != '0' >
									lay-verify="${fieldItem.required}"
								</#if>
							   type="hidden">
						<c:if test="${'$'}{empty ${generatorTable.className}.${fieldItem.fieldName}}">
							<img id="${fieldItem.fieldName}" class="layui-upload-img"
								 src="${'$'}{pageContext.request.contextPath}/static/images/addImg.png"
								 onclick="$selectFileManage(1,'${fieldItem.fieldName}')">
						</c:if>
						<c:if test="${'$'}{not empty ${generatorTable.className}.${fieldItem.fieldName}}">
							<img id="${fieldItem.fieldName}" class="layui-upload-img"
								 src="${'$'}{FILE_WEB_PATH}${'$'}{${generatorTable.className}.${fieldItem.fieldName}}"
								 onclick="$selectFileManage(1,'${fieldItem.fieldName}')">
							<div class="closeBtu" onclick="deleteFile('${'$'}{${generatorTable.className}.${fieldItem.fieldName}}',this)">
								<img src="/static/images/xbtn.png">
							</div>
						</c:if>
					</div>
				</div>
			</div>

					</#if>
					<#if fieldItem.inputType =='5'>
			<div class="layui-form-item">
				<label class="layui-form-label">${fieldItem.columnComment!""}</label>
				<div class="layui-input-block">
					<button type="button" class="layui-btn" onclick="$selectFileManage(2,'${fieldItem.fieldName}')">选择文件</button>
					<blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;" >
						预览图<font style="color: red">(可拖拽图标进行排序,排序后请点击保存按钮)</font>：
						<ul class="layui-upload-ul" id="${fieldItem.fieldName}">
							<c:if test="${'$'}{not empty ${generatorTable.className}.${fieldItem.fieldName}}">
								<c:forEach items='${'$'}{fn:split(${generatorTable.className}.${fieldItem.fieldName},",")}' var="item" >
									<li class="layui-upload-list" style="width:100px;">
										<input value="${'$'}{item}" type="hidden" class="fileUrlInput">
										<c:set var="fileExt" value="${'$'}{fn:substring(item,cyys:lastIndexOf(item, '.') + 1,item.length())}" />
										<img class="layui-upload-img"
										<c:choose>
											<c:when test="${'$'}{fileExt eq 'doc' || fileExt eq 'docx'}">
											src="${'$'}{pageContext.request.contextPath}/static/images/doc.png"
											</c:when>
											<c:when test="${'$'}{fileExt eq 'xsl' || fileExt eq 'xlsx'}">
											src="${'$'}{pageContext.request.contextPath}/static/images/xsl.png"
											</c:when>
											<c:when test="${'$'}{fileExt eq 'pdf'}">
											src="${'$'}{pageContext.request.contextPath}/static/images/pdf.png"
											</c:when>
											<c:when test="${'$'}{fileExt eq 'ppt' || fileExt eq 'pptx'}">
											src="${'$'}{pageContext.request.contextPath}/static/images/pptx.png"
											</c:when>
											<c:when test="${'$'}{fileExt eq 'gif' || fileExt eq 'jpg' || fileExt eq 'jpeg' || fileExt eq 'bmp' || fileExt eq 'png'}">
											src="${'$'}{FILE_WEB_PATH}${'$'}{item}"
											</c:when>
											<c:otherwise>
											src="${'$'}{pageContext.request.contextPath}/static/images/fileupload/wj.png"
											</c:otherwise>
										</c:choose>
										>
										<div class="closeBtu" onclick="deleteFile('${'$'}{item}',this,true)">
											<img src="/static/images/xbtn.png">
										</div>
									</li>
								</c:forEach>
							</c:if>
						</ul>
						<div style="clear:both;"></div>
					</blockquote>
					<input class="fileUrlsInput" value="${'$'}{${generatorTable.className}.${fieldItem.fieldName}}" name="${fieldItem.fieldName}" type="hidden">
				</div>
			</div>
					</#if>
					<#if fieldItem.inputType =='6'>
			<div class="layui-form-item">
				<label class="layui-form-label<#if fieldItem.required != '0'> layui-form-required</#if>">${fieldItem.columnComment!""}
				</label>
				<div class="layui-input-inline">
					<select  <#if fieldItem.required != '0'>lay-verify="${fieldItem.required}"</#if> name="${fieldItem.fieldName}">
						<c:forEach items="${'$'}{${fieldItem.paramName}_MAP}" var="t">
							<option value="${'$'}{t.key }" <c:if test="${'$'}{t.key eq ${generatorTable.className}.${fieldItem.fieldName}}">selected="selected"</c:if>>${'$'}{t.value }</option>
						</c:forEach>
					</select>
				</div>
			</div>

					</#if>
					<#if fieldItem.inputType =='7'>
			<div class="layui-form-item">
				<label class="layui-form-label">${fieldItem.columnComment!""}</label>
				<div class="layui-input-block">
					<textarea id="${fieldItem.fieldName}">${'$'}{${generatorTable.className}.${fieldItem.fieldName}}</textarea>
				</div>
			</div>
					</#if>
        		</#list>
			</#if>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
					<button type="button" class="layui-btn layui-btn-danger" onclick="closed()">关闭</button>
				</div>
			</div>
		</form>
	</div>
	</div>
</div>
	<script src="${'$'}{pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${'$'}{FILE_VERSION}"></script>
	<script src="${'$'}{pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${'$'}{FILE_VERSION}"></script>
	<script src="${'$'}{pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${'$'}{FILE_VERSION}"></script>
	<script src="${'$'}{pageContext.request.contextPath}/static/js/common/coreInput-2.0.0.js?v=${'$'}{FILE_VERSION}"></script>
	<#if generatorTable.inputTypes?contains("4") || generatorTable.inputTypesontains("5")>
	<script src="${'$'}{pageContext.request.contextPath}/static/js/upload/fileUpload.js?v=${'$'}{FILE_VERSION}"></script>
	</#if>
	<#if generatorTable.inputTypes?contains("7")>
	<script src="${'$'}{pageContext.request.contextPath}/ueditor/ueditor.config.js?v=${'$'}{FILE_VERSION}"></script>
	<script src="${'$'}{pageContext.request.contextPath}/ueditor/ueditor.all.min.js?v=${'$'}{FILE_VERSION}"> </script>
	<script src="${'$'}{pageContext.request.contextPath}/ueditor/lang/zh-cn/zh-cn.js?v=${'$'}{FILE_VERSION}"></script>
	</#if>
	<script>
		layui.config({
	  		base: getContextPath() + '/static/layuiadmin/'
	  	}).extend({
	  	}).use(['form', 'layer', 'laydate'], function() {
			var form = layui.form;
			<#if generatorTable.inputTypes?contains("3")>
			var laydate = layui.laydate;
				<#if generatorTable.fieldList?exists && generatorTable.fieldList?size gt 0>
				<#list generatorTable.fieldList as fieldItem >
					<#if fieldItem.inputType =='3'>
			laydate.render({
				elem: '#${fieldItem.fieldName}'
				,type: 'date'
				,range: false
			});
					</#if>
				</#list>
				</#if>
			</#if>

			form.on('submit(sub)', function(data){
				<#if generatorTable.fieldList?exists && generatorTable.fieldList?size gt 0>
				<#list generatorTable.fieldList as fieldItem >
				<#if fieldItem.inputType =='5'>
				data.field['${fieldItem.fieldName}'] = getMutifileUrl('#${fieldItem.fieldName}');
				</#if>
				<#if fieldItem.inputType =='7'>
				data.field['${fieldItem.fieldName}'] = ${fieldItem.fieldName}.getContent();
				</#if>
				</#list>
				</#if>
				return saveOrUpdate(${'$'}("#id").val(),"/${generatorTable.moudleName}/${generatorTable.shiro}",data);
			});

			<#if generatorTable.inputTypes?contains("7")>
			initEditor();
			</#if>
		});

		<#if generatorTable.inputTypes?contains("7")>
		<#if generatorTable.fieldList?exists && generatorTable.fieldList?size gt 0>
		<#list generatorTable.fieldList as fieldItem >
		<#if fieldItem.inputType =='7'>
		var ${fieldItem.fieldName};
		</#if>
		</#list>
		</#if>
		function initEditor() {
		<#if generatorTable.fieldList?exists && generatorTable.fieldList?size gt 0>
		<#list generatorTable.fieldList as fieldItem >
		<#if fieldItem.inputType =='7'>
			${fieldItem.fieldName} = UE.getEditor('${fieldItem.fieldName}', {
				initialFrameWidth: 500
				, initialFrameHeight: 400
				, toolbars: [[
					'fullscreen', 'source', '|', 'undo', 'redo', '|',
					'bold', 'italic', 'underline', 'fontborder', 'strikethrough', '|', 'forecolor', 'backcolor', '|',
					'fontfamily', 'fontsize',
					'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify','indent','|',
					'simpleupload', 'insertimage', 'insertvideo', 'emotion', 'scrawl', 'map', '|',
					'horizontal', 'date', 'time', 'spechars', '|',
					'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts',
					'preview'
				]]
			});

		</#if>
		</#list>
		</#if>
		}
		</#if>

		function ${generatorTable.className}Select(){
			var url  = getContextPath() +  "/${generatorTable.moudleName}/${generatorTable.shiro}/${generatorTable.className}Select";
			layer.open({
				title : "选择${generatorTable.tableComment!""}",
				type: 2,
				area: ['500px', '90%'],
				anim: 2,
				content: [url, 'yes']
			});
		}

		function set${generatorTable.upperClassName}(id,name){
			$("#parentId").val(id);
			$("#parentName").val(name);
			layer.closeAll();
		}
	</script>
</body>
</html>